package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "acao")
public class Action extends AbstractORM {
	
	private static final long serialVersionUID = 1L;
	
	private Integer actionId;
	private String actionName;
	private Double actionValueOne;
	private Double actionValueTwo;
	private Double actionValueTree;
	private Double actionValueFour;
	private Actuator actuator;
	private Set<Event> events = new HashSet<Event>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "cod_acao", unique = true, nullable = false)
	public Integer getActionId() {
		return actionId;
	}
	
	public void setActionId(Integer actionId) {
		this.actionId = actionId;
	}
	
	@Column(name = "nom_acao", nullable = false)
	public String getActionName() {
		return actionName;
	}
	
	public void setActionName(String actionName) {
		this.actionName = actionName;
	}
	
	@Column(name = "val_acao_1", nullable = true)
	public Double getActionValueOne() {
		return actionValueOne;
	}
	
	public void setActionValueOne(Double actionValueOne) {
		this.actionValueOne = actionValueOne;
	}
	
	@Column(name = "val_acao_2", nullable = true)
	public Double getActionValueTwo() {
		return actionValueTwo;
	}
	
	public void setActionValueTwo(Double actionValueTwo) {
		this.actionValueTwo = actionValueTwo;
	}
	
	@Column(name = "val_acao_3", nullable = true)
	public Double getActionValueTree() {
		return actionValueTree;
	}
	
	public void setActionValueTree(Double actionValueTree) {
		this.actionValueTree = actionValueTree;
	}
	
	@Column(name = "val_acao_4", nullable = true)
	public Double getActionValueFour() {
		return actionValueFour;
	}
	
	public void setActionValueFour(Double actionValueFour) {
		this.actionValueFour = actionValueFour;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cod_atuador", nullable = false)
	public Actuator getActuator() {
		return actuator;
	}
	
	public void setActuator(Actuator actuator) {
		this.actuator = actuator;
	}
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "acoes_evento", 
		joinColumns = { @JoinColumn(name = "cod_acao", nullable = false, updatable =  false) }, 
		inverseJoinColumns = { @JoinColumn(name = "cod_evento", nullable = false, updatable = false) })
	public Set<Event> getEvents() {
		return events;
	}
	
	public void setEvents(Set<Event> events) {
		this.events = events;
	}
	
}
